package com.example.mydy.withdraw;

/**
 * 提现数据管理器 - 单例模式
 * 用于管理整个提现流程中的数据共享
 */
public class WithdrawDataManager {
    
    private static WithdrawDataManager instance;
    
    // 提现数据
    private double withdrawAmount = 0.0; // 提现金额
    private String alipayAccount = "";   // 支付宝账号
    private String alipayName = "";      // 支付宝姓名
    private double serviceFee = 0.0;     // 服务费
    private int withdrawalId = -1;       // 提现记录ID
    private String withdrawalTime = "";  // 提现申请时间
    
    private WithdrawDataManager() {
        // 私有构造函数
    }
    
    public static synchronized WithdrawDataManager getInstance() {
        if (instance == null) {
            instance = new WithdrawDataManager();
        }
        return instance;
    }
    
    public double getWithdrawAmount() {
        return withdrawAmount;
    }
    
    public void setWithdrawAmount(double withdrawAmount) {
        this.withdrawAmount = withdrawAmount;
        // 计算服务费 (假设无服务费)
        this.serviceFee = 0.0;
    }
    
    public String getAlipayAccount() {
        return alipayAccount;
    }
    
    public void setAlipayAccount(String alipayAccount) {
        this.alipayAccount = alipayAccount;
    }
    
    public String getAlipayName() {
        return alipayName;
    }
    
    public void setAlipayName(String alipayName) {
        this.alipayName = alipayName;
    }
    
    public double getServiceFee() {
        return serviceFee;
    }
    
    public double getActualAmount() {
        return withdrawAmount - serviceFee;
    }
    
    public int getWithdrawalId() {
        return withdrawalId;
    }
    
    public void setWithdrawalId(int withdrawalId) {
        this.withdrawalId = withdrawalId;
    }
    
    public String getWithdrawalTime() {
        return withdrawalTime;
    }
    
    public void setWithdrawalTime(String withdrawalTime) {
        this.withdrawalTime = withdrawalTime;
    }
    
    /**
     * 清除数据
     */
    public void clear() {
        withdrawAmount = 0.0;
        alipayAccount = "";
        alipayName = "";
        serviceFee = 0.0;
        withdrawalId = -1;
        withdrawalTime = "";
    }
} 